from extension import db
from datetime import datetime

class AnswerModel(db.Model):
    __tablename__ = 'answer'
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    content = db.Column(db.Text, nullable=False)
    create_time = db.Column(db.DateTime, default=datetime.now)

    question_id = db.Column(db.Integer, db.ForeignKey('question.id'))
    question = db.relationship("QAModel", backref=db.backref('answers', order_by=id.desc()))

    author_id = db.Column(db.Integer, db.ForeignKey('user.id'))
    author = db.relationship("UserModel", backref="answers")